package cn.edu.njupt.post.service;

import cn.edu.njupt.post.dao.CommentDAO;
import cn.edu.njupt.post.model.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentService {
    @Autowired
    private CommentDAO commentDAO;


    public List<Comment> getCommentsByPost(int postId) {
        return commentDAO.selectByPost(postId);
    }


    public Comment getComment(int id) {
        return commentDAO.getCommentById(id);
    }

    public List<Comment> getCommentsByEntity(int entityId, int entityType) {
        return commentDAO.selectByEntity(entityId, entityType);
    }

    public int addComment(Comment comment) {
        return commentDAO.addComment(comment);
    }

    public int getCommentCount(int postId) {
        return commentDAO.getCommentCount(postId);
    }

    public int getUserCommentCount(int userId) {
        return commentDAO.getUserCommentCount(userId);
    }

    public void deleteComment(int id) {
        commentDAO.deleteById(id);
    }
}
